local scheduler = import("framework.scheduler")
local DaoJuBase =class("DaoJuBase",function() return display.newNode() end)
function DaoJuBase:ctor()
 
 local paopao = display.newSprite("#zhuandaoju0001.png",0,0)
 local frames =display.newFrames("zhuandaoju00%02d.png",1,19)
 local animation =display.newAnimation(frames, 1.0 / 19)
 display.setAnimationCache("ani",animation)


 self:addChild(paopao)
 self.sprite =paopao
 self.sprite:retain()
 self.isPass =false
end

function DaoJuBase:checkColliWithFish(fishRect)
     if not self:getParent() or not self:getParent():getParent() then return false end
     local layerX,layerY =self:getParent():getParent():getPosition()
     local uiX,uiY =self:getParent():getPosition()
     local x ,y =self:getPosition()
     local size =self.sprite:getContentSize()
     local width =size.width -60
     local height =size.height-60
     local rect =CCRect(layerX+uiX+x-width/2,layerY+uiY+y-height/2,width,height)
     if fishRect:intersectsRect(rect) then
         self:onColliWithFish()
         return true
     end
     return false
end


function DaoJuBase:getWidth()
 return self.sprite:getContentSize().width*0.5
end

function DaoJuBase:getHeight()
 return self.sprite:getContentSize().height*0.5
end

function DaoJuBase:onPass() --鱼从身边过了。但没有碰到道具
 self.isPass =true
end

function DaoJuBase:onColliWithFish() --道具触发
 self.isPass=true
 local animation = display.getAnimationCache("ani")
 local target =self.sprite
 transition.playAnimationOnce(target,animation,true,handler(self,self.onComplete))
end



function DaoJuBase:onComplete()

end


return DaoJuBase
